package 力扣日常刷题.木22二月.第08天214;

/**
 * @author 帅小伙
 * @date 2022/2/14
 * @description
 */
public class Demo60验证回文串 {


    public static void main(String[] args) {
        isPalindrome("1b1");
    }


    public static boolean isPalindrome(String s) {
        if (s.length() == 0) return true;
        s = s.toLowerCase();
        int i = 0, j = s.length() - 1;
        while (i < j) {
            try {
                while ((s.charAt(i) < 'a' || s.charAt(i) > 'z') && (s.charAt(i) < '0' || s.charAt(i) > '9')) i++;
                while ((s.charAt(j) < 'a' || s.charAt(j) > 'z') && (s.charAt(j) < '0' || s.charAt(j) > '9')) j--;
            } catch (Exception e) {
                return true;
            }
            if (s.charAt(i) != s.charAt(j)) return false;
            i++;
            j--;
        }
        return true;
    }

}
